package frmMantenimiento;

import cls.conexion;
import com.sun.glass.events.KeyEvent;
import frm.frmPrincipal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

public class frmTiposMovimiento extends javax.swing.JFrame {

    static conexion CP; // conexion con base de datos

    public frmTiposMovimiento() throws ClassNotFoundException, SQLException {
        initComponents();
        setLocationRelativeTo(null);
        noVer();
        CP = new conexion("proyecto2", "usrUTN", "12345");
        verdatos();
    }

    private void limpiarRd() {
        rdNo.setSelected(false);
        rdSi.setSelected(false);
        rdNo.setEnabled(true);
        rdSi.setEnabled(true);
    }

    // metodo que muestras los datos de la base de datos
    public void verdatos() {
        DefaultTableModel modelo = (DefaultTableModel) tblMovimientos.getModel();
        Object[] fila = new Object[8];
        modelo.setRowCount(0);
        try {
            ResultSet datos = this.CP.select("*", "\"schUTN\".tipo_movimiento", "");
            while (datos.next()) {
                fila[0] = datos.getString(1);
                fila[1] = datos.getString(2);
                fila[2] = datos.getString(3);
                fila[3] = datos.getString(4);
                modelo.addRow(fila);
            }
        } catch (Exception e) {
            System.out.printf("Error: " + e.toString());
        }
    }

    // oculta los botones
    public void noVer() {
        jLabel1.setVisible(false);
        jLabel2.setVisible(false);
        jLabel3.setVisible(false);
        jLabel4.setVisible(false);
        txtDescripcion.setVisible(false);
        txtTipoMovimiento.setVisible(false);
        rdNo.setVisible(false);
        rdSi.setVisible(false);
        cbxOperacion.setVisible(false);
        btnFinalizarModifiar.setVisible(false);
        btnFinalizarinsert.setVisible(false);
    }

    // muestra los botones
    public void Ver() {
        jLabel1.setVisible(true);
        jLabel2.setVisible(true);
        jLabel3.setVisible(true);
        jLabel4.setVisible(true);
        txtDescripcion.setVisible(true);
        txtTipoMovimiento.setVisible(true);
        rdNo.setVisible(true);
        rdSi.setVisible(true);
        cbxOperacion.setVisible(true);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        prueba = new javax.swing.JDialog();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblMovimientos = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        cbxOperacion = new javax.swing.JComboBox();
        txtDescripcion = new javax.swing.JTextField();
        txtTipoMovimiento = new javax.swing.JTextField();
        btnInsertar = new javax.swing.JButton();
        btnAtras = new javax.swing.JButton();
        btnModificar = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();
        btnFinalizarinsert = new javax.swing.JButton();
        btnFinalizarModifiar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        rdSi = new javax.swing.JRadioButton();
        rdNo = new javax.swing.JRadioButton();

        jLabel5.setText("sdfghjkuytreeeeeeeeeeeeeeeeeeeeeeeedfvb");

        javax.swing.GroupLayout pruebaLayout = new javax.swing.GroupLayout(prueba.getContentPane());
        prueba.getContentPane().setLayout(pruebaLayout);
        pruebaLayout.setHorizontalGroup(
            pruebaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        pruebaLayout.setVerticalGroup(
            pruebaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("MOVIMIEMTOS");

        tblMovimientos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Tipo Movimiento", "Descripcion", "Tipo Operacion", "Activo"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblMovimientos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblMovimientosMouseClicked(evt);
            }
        });
        tblMovimientos.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tblMovimientosKeyPressed(evt);
            }
        });
        jScrollPane1.setViewportView(tblMovimientos);
        if (tblMovimientos.getColumnModel().getColumnCount() > 0) {
            tblMovimientos.getColumnModel().getColumn(0).setResizable(false);
            tblMovimientos.getColumnModel().getColumn(1).setResizable(false);
            tblMovimientos.getColumnModel().getColumn(2).setResizable(false);
            tblMovimientos.getColumnModel().getColumn(3).setResizable(false);
        }

        jLabel1.setText("Tipo Movimiento");

        jLabel2.setText("Descripcion");

        jLabel3.setText("Tipo Operacion");

        cbxOperacion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "-1" }));
        cbxOperacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxOperacionActionPerformed(evt);
            }
        });
        cbxOperacion.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                cbxOperacionFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                cbxOperacionFocusLost(evt);
            }
        });
        cbxOperacion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cbxOperacionKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cbxOperacionKeyTyped(evt);
            }
        });

        btnInsertar.setText("Insertar");
        btnInsertar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnInsertarActionPerformed(evt);
            }
        });

        btnAtras.setText("Atras");
        btnAtras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAtrasActionPerformed(evt);
            }
        });

        btnModificar.setText("Modificar");
        btnModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarActionPerformed(evt);
            }
        });

        btnEliminar.setText("Eliminar");
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });

        btnFinalizarinsert.setText("Finalizar");
        btnFinalizarinsert.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFinalizarinsertActionPerformed(evt);
            }
        });

        btnFinalizarModifiar.setText("Finalizar");
        btnFinalizarModifiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFinalizarModifiarActionPerformed(evt);
            }
        });

        jLabel4.setText("Activo");

        rdSi.setText("SI");
        rdSi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdSiActionPerformed(evt);
            }
        });
        rdSi.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                rdSiFocusLost(evt);
            }
        });

        rdNo.setText("No");
        rdNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdNoActionPerformed(evt);
            }
        });
        rdNo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                rdNoFocusLost(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(34, 34, 34)
                                .addComponent(jLabel2)
                                .addGap(33, 33, 33)
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(43, 43, 43)
                                .addComponent(jLabel4))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(txtTipoMovimiento, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(30, 30, 30)
                                .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(27, 27, 27)
                                .addComponent(cbxOperacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(64, 64, 64)
                                .addComponent(rdSi, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rdNo, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(22, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnInsertar)
                            .addComponent(btnFinalizarinsert))
                        .addGap(26, 26, 26)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(2, 2, 2)
                                .addComponent(btnFinalizarModifiar))
                            .addComponent(btnModificar))
                        .addGap(32, 32, 32)
                        .addComponent(btnEliminar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnAtras, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))))
            .addComponent(jScrollPane1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(5, 5, 5)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rdSi)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(11, 11, 11)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtTipoMovimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cbxOperacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rdNo)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnFinalizarModifiar)
                    .addComponent(btnInsertar)
                    .addComponent(btnFinalizarinsert)
                    .addComponent(btnModificar)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnEliminar)
                        .addComponent(btnAtras))))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // boton insertar
    private void btnInsertarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInsertarActionPerformed
        // TODO add your handling code here:
        btnFinalizarinsert.setVisible(true);
        btnInsertar.setVisible(false);
                Ver();
                this.txtTipoMovimiento.requestFocus();
    }//GEN-LAST:event_btnInsertarActionPerformed

    // finaliza el insert
    private void btnFinalizarinsertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFinalizarinsertActionPerformed
        try {
            if (!(this.txtTipoMovimiento.getText().charAt(0) == ' ')) {
                try {
                    String si = "";
                    if (rdSi.isSelected()) {
                        si = "S";
                    } else {
                        if (rdNo.isSelected()) {
                            si = "N";
                        }
                    }
                    boolean resultado = this.CP.insert("\"schUTN\".tipo_movimiento",
                            "(" + "'" + this.txtTipoMovimiento.getText() + "'"
                            + ", " + "'" + this.txtDescripcion.getText() + "' , "
                            + "'" + this.cbxOperacion.getSelectedItem() + "', '"
                            + si + "' " + ");");
                } catch (Exception e) {
                    System.out.printf("Error: " + e.toString());
                }
                limpiar();
                int validar = JOptionPane.showConfirmDialog(
                        null,
                        "Deseas Realizar Otra operacion",
                        "  ",
                        JOptionPane.YES_NO_OPTION);
                if (validar == JOptionPane.YES_OPTION) {
                    verdatos();
                    limpiar();
                } else {
                    verdatos();
                    noVer();
                    this.btnInsertar.setVisible(true);
                    this.btnModificar.setVisible(true);
                    this.btnEliminar.setVisible(true);
                }
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Codigo Obligatorio");
        }
        limpiarRd();
    }//GEN-LAST:event_btnFinalizarinsertActionPerformed

    // metodo limpiar
    public void limpiar() {
        txtDescripcion.setText("");
        txtTipoMovimiento.setText("");
    }

    // boton atras para la ventana principal
    private void btnAtrasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAtrasActionPerformed
        setVisible(false);
        frmPrincipal o = new frmPrincipal();
        o.setVisible(true);
    }//GEN-LAST:event_btnAtrasActionPerformed

    // evento para el click para que muestre los datos en los campos respectivos
    private void tblMovimientosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblMovimientosMouseClicked
limpiarRd();
        String cod;
        DefaultTableModel modelo = (DefaultTableModel) tblMovimientos.getModel();
        int vector[] = tblMovimientos.getSelectedRows();
        int in = tblMovimientos.getSelectedRow();

        cod = (String) tblMovimientos.getValueAt(in, 0);
        txtTipoMovimiento.setText(cod);

        cod = (String) tblMovimientos.getValueAt(in, 1);
        txtDescripcion.setText(cod);
        
        cod = (String) tblMovimientos.getValueAt(in, 3);
        if (cod.equals("S")) {
            rdSi.setSelected(true);

        } else {
            rdNo.setSelected(true);
        }

        if (rdSi.isSelected()) {
            rdNo.setEnabled(false);
        } else {
            rdNo.setEnabled(true);
        }

        if (rdNo.isSelected()) {
            rdSi.setEnabled(false);

        } else {
            rdSi.setEnabled(true);
        }
        
       
        
    }//GEN-LAST:event_tblMovimientosMouseClicked

    // boton modificar
    private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed
        noVer();
        btnFinalizarModifiar.setVisible(true);
        Ver();
        btnModificar.setVisible(false);
        btnFinalizarinsert.setVisible(false);
        btnInsertar.setVisible(true);
        this.txtTipoMovimiento.requestFocus();
        
    }//GEN-LAST:event_btnModificarActionPerformed

    // finaliza el modificar
    private void btnFinalizarModifiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFinalizarModifiarActionPerformed
        String cod;
        DefaultTableModel modelo = (DefaultTableModel) tblMovimientos.getModel();
        int vector[] = tblMovimientos.getSelectedRows();
        int in = tblMovimientos.getSelectedRow();
        if (in == -1) {
            JOptionPane.showMessageDialog(null, "Selecione un valor valido");
        } else {
            for (int i = 0; i < vector.length; i++) {
                cod = (String) tblMovimientos.getValueAt(in, 0);
                try {
                    String si = "";
                    if (rdSi.isSelected()) {
                        si = "S";
                    } else {
                        if (rdNo.isSelected()) {
                            si = "N";
                        }
                    }
                    boolean resultado = this.CP.actualizar("\"schUTN\".tipo_movimiento",
                            " tipo_movimiento= " + "'" + this.txtTipoMovimiento.getText() + "'"
                            + ", " + " descripcion= " + " '" + this.txtDescripcion.getText() + "' , "
                            + "tipo_operacion= " + "'" + this.cbxOperacion.getSelectedItem() + "',"
                            + " activo= " + "'" + si
                            + "' ", "tipo_movimiento= " + "'" + cod + "'");
                } catch (Exception e) {
                    System.out.printf("Error: " + e.toString());
                }
            }
        }
        limpiarRd();
        verdatos();
        noVer();
        btnModificar.setVisible(true);
    }//GEN-LAST:event_btnFinalizarModifiarActionPerformed

    // boto eliminar
    private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
        noVer();
        btnModificar.setVisible(true);
        int validar = JOptionPane.showConfirmDialog(
                null,
                "Estas Seguro?",
                " CUIDADO",
                JOptionPane.YES_NO_OPTION);
        if (validar == JOptionPane.YES_OPTION) {
            try {
                boolean resultado = this.CP.eliminar("\"schUTN\".tipo_movimiento",
                        "tipo_movimiento= " + "'" + this.txtTipoMovimiento.getText() + "'");
            } catch (Exception e) {
                System.out.printf("Error: " + e.toString());
            }
            verdatos();
        } else {
            verdatos();
        }
        limpiarRd();
    }//GEN-LAST:event_btnEliminarActionPerformed

    private void rdSiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdSiActionPerformed
        
            
            if (rdSi.isSelected()) {
            rdNo.setEnabled(false);
            
           if(this.btnFinalizarModifiar.isEnabled()==true)
           {
               this.btnFinalizarModifiar.requestFocus();
           }
          
           
               if (this.btnFinalizarinsert.isEnabled()==true) {
                   
                   this.btnFinalizarinsert.requestFocus();
               }
               
           
            
        } else {
            rdNo.setEnabled(true);
        }
                      
      
    }//GEN-LAST:event_rdSiActionPerformed

    private void rdNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdNoActionPerformed
        if (rdNo.isSelected()) {
            rdSi.setEnabled(false);
            
            if(this.btnFinalizarModifiar.isEnabled()==true)
           {
               this.btnFinalizarModifiar.requestFocus();
           }
          
           
               if (this.btnFinalizarinsert.isEnabled()==true) {
                   
                   this.btnFinalizarinsert.requestFocus();
               }

        } else {
            rdSi.setEnabled(true);
        }
    }//GEN-LAST:event_rdNoActionPerformed

    private void cbxOperacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxOperacionActionPerformed
        
       
        
       
    }//GEN-LAST:event_cbxOperacionActionPerformed

    private void cbxOperacionKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cbxOperacionKeyTyped
      
    }//GEN-LAST:event_cbxOperacionKeyTyped

    private void cbxOperacionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cbxOperacionKeyPressed
       
        
    }//GEN-LAST:event_cbxOperacionKeyPressed

    private void cbxOperacionFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cbxOperacionFocusGained
        // TODO add your handling code here:  
        
      
        
    }//GEN-LAST:event_cbxOperacionFocusGained

    private void cbxOperacionFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cbxOperacionFocusLost
        // TODO add your handling code here:
        if (rdSi.isSelected()==false && rdNo.isSelected()==false) {
            this.rdSi.requestFocus();
        }else{
            if (rdSi.isSelected()==true) {
                rdSi.requestFocus();
            }else{
                rdNo.requestFocus();
            }
        }
          
    }//GEN-LAST:event_cbxOperacionFocusLost

    private void rdSiFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_rdSiFocusLost
        if (this.rdSi.isSelected()==true) {
            
            if(this.btnFinalizarModifiar.isEnabled()==true)
           {
               this.btnFinalizarModifiar.requestFocus();
           }
          
           
               if (this.btnFinalizarinsert.isEnabled()==true) {
                   
                   this.btnFinalizarinsert.requestFocus();
               }
            
        }else{
            
            if(rdSi.isSelected()==false&&rdNo.isSelected()==true)
            {
                this.rdNo.requestFocus();
            }
           
          
    }
    }//GEN-LAST:event_rdSiFocusLost

    private void rdNoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_rdNoFocusLost
       if (rdNo.isSelected()==true) {
            rdSi.setEnabled(false);
                  if(this.btnFinalizarModifiar.isEnabled()==true)
           {
               this.btnFinalizarModifiar.requestFocus();
           }
          
           
               if (this.btnFinalizarinsert.isEnabled()==true) {
                   
                   this.btnFinalizarinsert.requestFocus();
               }
               
        } else {
            rdSi.setEnabled(true);
        }
           
           if(rdNo.isSelected()==false&&rdSi.isSelected()==false)
       {
           this.rdSi.requestFocus();
       }
    }//GEN-LAST:event_rdNoFocusLost

    private void tblMovimientosKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblMovimientosKeyPressed
        // TODO add your handling code here:
      
        char tecla=evt.getKeyChar();
        if(evt.getKeyCode()==KeyEvent.VK_ESCAPE)
        {
            setVisible(false);
            frmPrincipal F = new frmPrincipal();
            F.setVisible(true);
          
            
        }
    }//GEN-LAST:event_tblMovimientosKeyPressed

    // metodo Main Generado por JAVA
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(() -> {
            try {
                new frmTiposMovimiento().setVisible(true);
            } catch (ClassNotFoundException | SQLException ex) {
                Logger.getLogger(frmTiposMovimiento.class.getName()).log(Level.SEVERE, null, ex);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAtras;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnFinalizarModifiar;
    private javax.swing.JButton btnFinalizarinsert;
    private javax.swing.JButton btnInsertar;
    private javax.swing.JButton btnModificar;
    private javax.swing.JComboBox cbxOperacion;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JDialog prueba;
    private javax.swing.JRadioButton rdNo;
    private javax.swing.JRadioButton rdSi;
    private javax.swing.JTable tblMovimientos;
    private javax.swing.JTextField txtDescripcion;
    private javax.swing.JTextField txtTipoMovimiento;
    // End of variables declaration//GEN-END:variables
}
